# -*-coding:utf-8 -*-

"""
# File       : weixinPackage.py
# Time       ：2022/10/14 下午2:09
# Author     ：puppet
# version    ：python 3.8.1
# Description：
"""

import requests
from bs4 import BeautifulSoup


def getWeixinData():
    doubanUrl = 'http://www.jsrank.cn/real/1b86113757e8a585bc0f656399cfb647.html'
    headers = {
        "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36'
    }
    res = requests.get(url=doubanUrl, headers=headers)
    resultList = []
    if res.status_code == 200:
        soup = BeautifulSoup(res.text, "html.parser")
        items = soup.find_all('div', class_='item')
        for item in items:
            index = item.find_all('span')[0].string
            articleName = str(item.find_all('a')[0].string).split('」')[1]
            viewNum = str(item.find_all('span')[2].string).split(',')[0]
            readingNum = str(item.find_all('span')[2].string).split(',')[1]
            sougouSearchUrl = 'https://weixin.sogou.com/weixinwap?query={}&ie=utf8&s_from=input&type=2&pg=webSearchList'.format(articleName)
            tempList = [index, articleName, sougouSearchUrl, viewNum, readingNum]
            resultList.append(tempList)
            print(tempList)
    return resultList
